var orderAllURL = "./json/orderAll.json";
$(document).ready(function(){
  $.get(orderAllURL, function(res){
    if(res.serviceResult){
      var data = res.resultParm.list;
      var html = "";
      for(var i=0;i<data.length;i++){
        var statusWord;var type;var but="";
        switch (data[i].status) {
          case 0:statusWord="待接单";break;
          case 1:statusWord="服务中";break;
          case 2:statusWord="已完成";break;
          default:break;
        }
        switch (data[i].typeid) {
          case 0:type="上市策划";break;
          case 1:type="整账顾问";break;
          case 2:type="工商代理";break;
          case 3:type="代理记账";break;
          case 4:type="税审资讯";break;
          case 5:type="税务顾问";break;
          case 6:type="财审咨询";break;
          case 7:type="财务顾问";break;
          default:break;
        }
        if(data[i].status==0){
          but = '<button>去付款</button>';
        }
        html += 	'<div class="section order">'+
                		'<div class="order-item panel">'+
                			'<div class="row header">'+
                				'<div class="order-id col-16">订单号：'+data[i].id+'</div>'+
                				'<div class="col-8">订单状态：<span class="status">'+statusWord+'</span></div>'+
                			'</div>'+
                			'<div class="row content">'+
                				'<a class="orderLink" data-id="'+data[i].id+'" href="orderDetail"><div class="col-16">'+
                					'<img class="avatar" src='+ data[i].img +' alt="">'+
                					'<div class="main">'+
                						'<p class="username">'+ data[i].name +'</p>'+
                						'<p class="order-type">服务类型： <span>'+type+'</span></p>'+
                					'</div>'+
                				'</div></a>'+
                				'<div class="col-8">'+
                					'<span class="price">¥'+data[i].money+'</span>'+
                					but+
                				'</div>'+
                			'</div>'+
                		'</div>'+
                	'</div>';
      }
      $(".contain").empty().append(html);
    }
  });
  $("body").find(".contain").on('click', '.orderLink', function(){
    var id = $(this).attr("data-id");
    sessionStorage.orderId = id;
  });

});
